package com.jt.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author 张琪
 * @date 2020/11/27
 * @describe
 */
@Data
@AllArgsConstructor
public class SysResult {
    private int status = 200;           //200为成功, 201为失败
    private String msg = "OK";
    private Object data;

    public SysResult() {
    }

    public SysResult(String msg) {
        this.msg = msg;
    }

    public SysResult(Object data) {
        this.data = data;
    }

    public SysResult(Throwable e) {
        status = 201;
        msg = e.getMessage();
    }

    public static SysResult fault() {
        return new SysResult(201, "业务执行错误", null);
    }

    public static SysResult success() {
        return new SysResult(200, "业务执行成功", null);
    }

    public static SysResult success(Object data) {
        return new SysResult(200, "业务执行成功", data);
    }

    public static SysResult success(String msg, Object data) {
        return new SysResult(200, msg, data);
    }

}
